﻿// CFrame.cs
// Author: Gant Briseno
#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace Casters.source.Animation
{
    /// <summary>
    /// A single frame for use in animations
    /// </summary>
    public class CFrame
    {
        public Vector2 m_AnchorPoint;
        public Vector2 m_AttackOffset;
        public Vector2 m_CollideOffset;
        public Rectangle m_AttackRect;
        public Rectangle m_CollideRect;
        public Rectangle m_ImageRect;
        public string m_Trigger;
        public float m_FrameTime;
        public bool m_bCheckCollision;

        public Vector2 Size
        {
            get
            {
                return new Vector2(m_ImageRect.Width, m_ImageRect.Height);
            }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="anchorPoint">Origin point for frame</param>
        /// <param name="attack">Attack Box</param>
        /// <param name="collision">Hit Box</param>
        /// <param name="image">Position of image</param>
        /// <param name="frameTime">Time to display image</param>
        /// <param name="trigger">Special trigger to fire off</param>
        public CFrame(Vector2 anchorPoint, Rectangle attack, Rectangle collision,
            Rectangle image, float frameTime, string trigger)
        {
            m_AnchorPoint = anchorPoint;
            m_AttackRect = attack;
            m_CollideRect = collision;
            m_ImageRect = image;
            m_FrameTime = frameTime;
            m_Trigger = trigger;

            m_AnchorPoint.X -= (float)image.X;
            m_AnchorPoint.Y -= (float)image.Y;

            // Calculate offsets
            m_AttackOffset = new Vector2(m_AnchorPoint.X - m_AttackRect.Left, m_AnchorPoint.Y - m_AttackRect.Top);
            m_CollideOffset = new Vector2(m_AnchorPoint.X - m_CollideRect.Left, m_AnchorPoint.Y - m_CollideRect.Top);
        }
    }
}
